View Javadoc

1   /*
2   * Copyright 2005 Arnaud Prost
3   * 
4   * Arnaud.prost@gmail.com
5   * 
6   * This software is a computer program whose purpose is to ease the 
7   * management of software project.
8   * 
9   * This software is governed by the CeCILL  license under French law and
10  * abiding by the rules of distribution of free software.  You can  use, 
11  * modify and/ or redistribute the software under the terms of the CeCILL
12  * license as circulated by CEA, CNRS and INRIA at the following URL
13  * "http://www.cecill.info". 
14  * 
15  * As a counterpart to the access to the source code and  rights to copy,
16  * modify and redistribute granted by the license, users are provided only
17  * with a limited warranty  and the software's author,  the holder of the
18  * economic rights,  and the successive licensors  have only  limited
19  * liability. 
20  * 
21  * In this respect, the user's attention is drawn to the risks associated
22  * with loading,  using,  modifying and/or developing or reproducing the
23  * software by the user in light of its specific status of free software,
24  * that may mean  that it is complicated to manipulate,  and  that  also
25  * therefore means  that it is reserved for developers  and  experienced
26  * professionals having in-depth computer knowledge. Users are therefore
27  * encouraged to load and test the software's suitability as regards their
28  * requirements in conditions enabling the security of their systems and/or 
29  * data to be ensured and,  more generally, to use and operate it in the 
30  * same conditions as regards security. 
31  * 
32  * The fact that you are presently reading this means that you have had
33  * knowledge of the CeCILL license and that you accept its terms.
34  */
35  
36  package net.sf.pmr.agilePlanning;
37  
38  import net.sf.pmr.agilePlanning.data.iteration.IterationMapper;
39  import net.sf.pmr.agilePlanning.data.release.ReleaseMapper;
40  import net.sf.pmr.agilePlanning.data.story.StoryMapper;
41  import net.sf.pmr.agilePlanning.data.story.task.TaskMapper;
42  import net.sf.pmr.agilePlanning.domain.iteration.Iteration;
43  import net.sf.pmr.agilePlanning.domain.iteration.IterationValidator;
44  import net.sf.pmr.agilePlanning.domain.release.Release;
45  import net.sf.pmr.agilePlanning.domain.release.ReleaseValidator;
46  import net.sf.pmr.agilePlanning.domain.story.Story;
47  import net.sf.pmr.agilePlanning.domain.story.StoryRepository;
48  import net.sf.pmr.agilePlanning.domain.story.task.Task;
49  import net.sf.pmr.agilePlanning.domain.story.task.TaskValidator;
50  import net.sf.pmr.agilePlanning.service.IterationService;
51  import net.sf.pmr.agilePlanning.service.ReleaseService;
52  import net.sf.pmr.agilePlanning.service.StoryService;
53  import net.sf.pmr.core.CoreObjectFactory;
54  import net.sf.pmr.keopsframework.domain.validation.Errors;
55  
56  import org.springframework.beans.factory.BeanFactory;
57  import org.springframework.context.access.ContextSingletonBeanFactoryLocator;
58  
59  /***
60   * @author Arnaud
61   */
62  public final class AgilePlanningObjectFactory {
63  
64      /***
65       * private constructor
66       */
67      private AgilePlanningObjectFactory() {
68      }
69  
70      /***
71       * get the address
72       * @return address
73       */
74      public static Errors getErrors() {
75  
76          return (Errors) AgilePlanningObjectFactory.getObject("agilePlanningErrors");
77      }
78  
79      
80      /***
81       * get the story
82       * @return story
83       */
84      public static Story getStory() {
85  
86          return (Story) AgilePlanningObjectFactory.getObject("story");
87      }
88      
89      /***
90       * get the story service
91       * @return story service
92       */
93      public static StoryService getStoryService() {
94  
95          return (StoryService) AgilePlanningObjectFactory.getObject("storyService");
96      }
97  
98      /***
99       * get the story repository
100      * @return story repository
101      */
102     public static StoryRepository getStoryRepository() {
103 
104         return (StoryRepository) AgilePlanningObjectFactory.getObject("storyRepository");
105     }
106     
107 
108     
109     /***
110      * get the iteration
111      * @return iteration
112      */
113     public static Iteration getIteration() {
114 
115         return (Iteration) AgilePlanningObjectFactory.getObject("iteration");
116     }
117     
118     
119     /***
120      * get the iteration service
121      * @return iteration service
122      */
123     public static IterationService getIterationService() {
124 
125         return (IterationService) AgilePlanningObjectFactory.getObject("iterationService");
126     }
127 
128 
129 
130     /***
131      * get the release validator
132      * @return releaseValidator
133      */
134     public static ReleaseValidator getReleaseValidator() {
135 
136         return (ReleaseValidator) AgilePlanningObjectFactory.getObject("releaseValidator");
137 
138     }
139 
140     /***
141      * get the release
142      * @return release
143      */
144     public static Release getRelease() {
145 
146         return (Release) AgilePlanningObjectFactory.getObject("release");
147 
148     }
149     
150     
151     /***
152      * get the release service
153      * @return release service
154      */
155     public static ReleaseService getReleaseService() {
156 
157         return (ReleaseService) AgilePlanningObjectFactory.getObject("releaseService");
158 
159     }
160 
161 
162     /***
163      * get the task
164      * @return task
165      */
166     public static Task getTask() {
167 
168         return (Task) AgilePlanningObjectFactory.getObject("task");
169 
170     }
171 
172     /***
173      * get the task mapper
174      * @return task mapper
175      */
176 
177     public static TaskMapper getTaskMapper() {
178 
179         return (TaskMapper) AgilePlanningObjectFactory.getObject("taskMapper");
180 
181     }
182 
183 
184     /***
185      * get the iteration validator
186      * @return iterationValidator
187      */
188     public static IterationValidator getIterationValidator() {
189 
190         return (IterationValidator) AgilePlanningObjectFactory.getObject("iterationValidator");
191 
192     }
193 
194     /***
195      * get the task validator
196      * @return taskValidator
197      */
198     public static TaskValidator getTaskValidator() {
199 
200         return (TaskValidator) AgilePlanningObjectFactory.getObject("taskValidator");
201 
202     }
203 
204 
205     /***
206      * get the iteration mapper
207      * @return iterationMapper
208      */
209     public static IterationMapper getIterationMapper() {
210 
211         return (IterationMapper) AgilePlanningObjectFactory.getObject("iterationMapper");
212 
213     }
214 
215     /***
216      * get the release mapper
217      * @return releaseMapper
218      */
219     public static ReleaseMapper getReleaseMapper() {
220 
221         return (ReleaseMapper) AgilePlanningObjectFactory.getObject("releaseMapper");
222 
223     }
224 
225     /***
226      * get the story mapper
227      * @return storyMapper
228      */
229     public static StoryMapper getStoryMapper() {
230 
231         return (StoryMapper) AgilePlanningObjectFactory.getObject("storyMapper");
232 
233     }
234 
235     /***
236      * get an object from the Spring application context
237      * @param objectName objectName
238      * @return object object
239      */
240     private static Object getObject(final String objectName) {
241 
242         return ContextSingletonBeanFactoryLocator.getInstance().useBeanFactory(
243                 "net.sf.pmr.agilePlanning").getFactory().getBean(objectName);
244 
245     }
246 
247     /***
248      * get the bean factory
249      * @return beanFactory
250      */
251     private static BeanFactory getBeanFactory() {
252 
253         return ContextSingletonBeanFactoryLocator.getInstance().useBeanFactory(
254                 "net.sf.pmr.agilePlanning").getFactory();
255     }
256 
257     /***
258      * is an object singleton ?
259      * @param object object
260      * @return boolean boolean
261      */
262     public static boolean isSingleton(final String object) {
263 
264         return AgilePlanningObjectFactory.getBeanFactory().isSingleton(object);
265 
266     }
267 
268 }